/*********************************************************************************/
/*                                                                               */
/*      WDG Driver                                                               */
/*                                                                               */
/*      Last updated by:   CBS                                                   */
/*      Last update date:  2013/2/8                                              */
/*      Revision:          0                                                     */
/*      Copyright:         DENSO                                                 */
/*                                                                               */
/*********************************************************************************/

#ifndef WDGSWT_H
#define WDGSWT_H

/*********************************************************************************/
/*  include files                                                                */
/*********************************************************************************/
#include "WdgIf_Types.h"
#include "Wdg_SwtCfg.h"

/*********************************************************************************/
/*  defines / data types / structs / unions / macros                             */
/*********************************************************************************/
#define WDG_VENDOR_ID        (U2)1
#define MODULE_ID_WDG        (U2)102
#define WDG_INSTANCE_ID      (U1)0

#define WDG_SW_MAJOR_VERSION (U1)1
#define WDG_SW_MINOR_VERSION (U1)0
#define WDG_SW_PATCH_VERSION (U1)0

#define WDG_AR_MAJOR_VERSION (U1)1
#define WDG_AR_MINOR_VERSION (U1)0
#define WDG_AR_PATCH_VERSION (U1)0

/* Service ID */
#define WDG_INIT_SERVICE_ID                 0x00
#define WDG_SETMODE_SERVICE_ID              0x01
#define WDG_SETTRIGGERCONDITION_SERVICE_ID  0x03
#define WDG_GETVERSIONINFO_SERVICE_ID       0x04

/* Error Codes */
#define WDG_E_DRIVER_STATE                  0x10
#define WDG_E_PARAM_MODE                    0x11
#define WDG_E_PARAM_CONFIG                  0x12
#define WDG_E_PARAM_TIMEOUT                 0x13
#define WDG_E_PARAM_POINTER                 0x14

typedef enum
{
    WDG_FIXED_SERVICE_MODE,
    WDG_KEYED_SERVICE_MODE
}Wdg_ServiceMode;

typedef struct
{
    U2 TimeServiceWatchDog;  /* Time value(milliseconds) for servicing the watch dog */
    U2 TimeOut;  /* Timeout value(milliseconds) for setting the trigger counter */
}Wdg_SettingType;

typedef struct
{
    U1 GptChannel;
    Wdg_ServiceMode ServiceMode;
    const Wdg_SettingType* SettingsOff;  /* WDG122_Conf */
    const Wdg_SettingType* SettingsSlow;  /* WDG123_Conf */
    const Wdg_SettingType* SettingsFast;  /* WDG121_Conf */
    WdgIf_ModeType DefaultMode;  /* WDG120_Conf */
}Wdg_ConfigType;

/*********************************************************************************/
/*  API Functions                                                             */
/*********************************************************************************/

/***************************************************************************************************/
/*  Service name    :   Wdg_Init                                                                   */
/*  Sync/Async      :   Synchronous                                                                */
/*  Reentrancy      :   Non Reentrant                                                              */
/*  Parameters (in) :   Pointer to configuration set.                                              */
/*  Return value    :   None                                                                       */
/*  Discription     :   Initialize the module.                                                     */
/***************************************************************************************************/
void Wdg_Init(const Wdg_ConfigType* ConfigPtr);

/***************************************************************************************************/
/*  Service name    :   Wdg_SetMode                                                                */
/*  Sync/Async      :   Synchronous                                                                */
/*  Reentrancy      :   Non Reentrant                                                              */
/*  Parameters (in) :   WdgIf_ModeType    Mode                                                     */
/*  Return value    :   Std_ReturnTpye    E_OK: command has been accepted.                         */
/*                                        E_NOT_OK: command has not been accepted.                 */
/*  Discription     :   Switch the watchdog into the statically configured mode.                   */
/***************************************************************************************************/
Std_ReturnType Wdg_SetMode(WdgIf_ModeType Mode);

/***************************************************************************************************/
/*  Service name    :   Wdg_SetTriggerCondition                                                    */
/*  Sync/Async      :   Synchronous                                                                */
/*  Reentrancy      :   Non Reentrant                                                              */
/*  Parameters (in) :   uint16 timeout:Timeout value(milliseconds) for setting the trigger counter.*/
/*  Return value    :   None                                                                       */
/*  Discription     :   Switch the watchdog into the statically configured mode.                   */
/***************************************************************************************************/
void Wdg_SetTriggerContidion(U2 timeout);

/********************************************************************************************************/
/*  Service name    :   Wdg_GetVersionInfo                                                              */
/*  Sync/Async      :   Synchronous                                                                     */
/*  Reentrancy      :   Reentrant                                                                       */
/*  Parameters (in) :   versioninfo   Pointer to where to store the version information of this module. */
/*  Return value    :   None                                                                            */
/*  Discription     :   Return the version information of this module.                                  */
/********************************************************************************************************/
#if(WDG_VERSION_INFO_API == STD_ON)  /* WDG068 */
void Wdg_GetVersionInfo(Std_VersionInfoType* versioninfo);
#endif  /* WDG_VERSION_INFO_API */

#endif  /* WDGSWT_H */
/**** End Of File ****************************************************************/
